import { commonRequest } from '@/api/commonHttp';

// 关联分类 - 表单查询
export const getByCategoryNameService = (data, target) => commonRequest({
  url: `/sysback/choose/category/searchCategoryList?categoryNo=${data.categoryNo}&categoryName=${data.categoryName}`,
  type: 'post',
  data,
  target
})

// 关联分类 - 分类树查询
export const getByParentUuidsService = (data, loadingFn) => commonRequest({
  url: '/sysback/choose/category/getByParentUuids',
  type: 'post',
  data,
  loadingFn
})

// 关联分类 - 分类已关联结果查询
export const getcategoryUuidsByLabelUuidService = (data, target) => commonRequest({
  url: '/sysback/labelcaterel/getcategoryUuidsByLabelUuid',
  type: 'post',
  data,
  target,
  isFormData: true
})

// 关联分类 - 分类提交
export const createRelateLabelService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelcaterel/createRelateLabel',
  type: 'post',
  data,
  loadingFn,
  isFormData: true
})

// 关联商品 - 未关联商品查询
export const getNotRelByCondition = (data, loadingFn) => commonRequest({
  url: `/sysback/labelskurel/getNotRelByCondition?labelUuid=${data.labelUuid}`,
  type: 'post',
  data,
  loadingFn
})

// 关联商品 - 已关联商品查询
export const getRelByCondition = (data, loadingFn) => commonRequest({
  url: `/sysback/labelskurel/getRelByCondition?labelUuid=${data.labelUuid}`,
  type: 'post',
  data,
  loadingFn
})

// 关联商品 - 删除已关联商品
export const deleteRelateService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelskurel/deleteRelate',
  type: 'post',
  data,
  loadingFn,
})

// 关联商品 - 增加未关联商品
export const createRelateService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelskurel/createRelate',
  type: 'post',
  data,
  loadingFn,
})

// 列表页 - 表单查询
export const queryLabelListService = (data, loadingFn) => commonRequest({
  url: '/sysback/label/queryLabelList',
  type: 'post',
  data,
  loadingFn
})

// 新增页 - 表单提交
export const addLabelService = (data, loadingFn) => commonRequest({
  url: '/sysback/label/addLabel',
  type: 'post',
  data,
  loadingFn
})

// 编辑页 - 表单提交
export const updateLabelService = (data, loadingFn) => commonRequest({
  url: '/sysback/label/updateLabel',
  type: 'post',
  data,
  loadingFn
})

// 编辑页 - 单据查询
export const queryLabelByIdService = (data, target) => commonRequest({
  url: '/sysback/label/queryLabelById',
  type: 'get',
  data,
  target
})

// 核心商品 - 规则导入
export const importCoreRuleUrl = 'sysback/labelRule/importRule4CoreProduct'

// 核心商品 - 规则查询
export const queryCoreProductRuleService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/queryCoreProductRule',
  type: 'post',
  data,
  loadingFn
})

// 核心商品 - 规则编辑导入后提交
export const commitCoreProductRuleService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/commitCoreProductRule',
  type: 'post',
  data,
  loadingFn
})

// 核心商品 - 导出规则 - 导出全部和异常数据
export const exportCoreProductRuleService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/exportCoreProductRule',
  type: 'post',
  data,
  loadingFn,
  isExport: true
})

// 核心商品 - 规则配置 - 一键清除异常信息数据
export const delCoreProductErrorService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/delCoreProductError',
  type: 'post',
  data,
  loadingFn
})

// 畅销商品规则编辑
export const saveHotSellRuleService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/saveHotSellRule',
  type: 'post',
  data,
  loadingFn
})

// 畅销商品规则查询
export const queryHotSellRule = (data, target) => commonRequest({
  url: '/sysback/labelRule/queryHotSellRule',
  type: 'post',
  data,
  target
})

// 查看商品 - 核心商品/畅销商品/售价准确性/重点商品
export const queryLabelProductService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRuleRel/queryLabelProduct',
  type: 'post',
  data,
  loadingFn
})

// 畅销商品 - 规则配置 - 导出SKU明细
export const exportHotSellSkuService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRuleRel/exportHotSellSku',
  type: 'post',
  data,
  loadingFn,
  isExport: true
})

// 重点商品 - 规则导入
export const importKeyRuleUrl = 'sysback/labelRule/importRule4KeyProduct'

// 重点商品 - 规则查询
export const queryKeyProductRuleService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/queryKeyProductRule',
  type: 'post',
  data,
  loadingFn
})

// 重点商品 - 规则编辑导入后提交
export const commitKeyProductRuleService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/commitKeyProductRule',
  type: 'post',
  data,
  loadingFn
})

// 重点商品 - 导出规则 - 导出全部和异常数据
export const exportKeyProductRuleService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/exportKeyProductRule',
  type: 'post',
  data,
  loadingFn,
  isExport: true
})

// 重点商品 - 规则配置 - 一键清除异常信息数据
export const delKeyProductErrorService = (data, loadingFn) => commonRequest({
  url: '/sysback/labelRule/delKeyProductError',
  type: 'post',
  data,
  loadingFn
})
